/*
 * @Author: JohnYang
 * @Date: 2020-09-23 17:37:58
 * @LastEditors: JohnYang
 * @LastEditTime: 2020-11-01 20:21:08
 */
import { downloadPdf } from "@/api";
export default {
  data() {
    return {
      search: {
        contractNumber: "",
        region: "",
        frameNum: "",
        dealerName: "",
        userName: "",
        createTime: []
      }
    };
  },
  methods: {
    handleSearch() {
      this.reloadTable(true);
    },
    async handleDownload(data) {
      try {
        let resp = await downloadPdf({ id: data.id, type: data.type });
        if (resp && resp.data) {
          window.open(resp.data.url);
        } else {
          this.$interaction.showError("无法获取下载链接!");
        }
      } catch (exp) {
        console.error(exp);
      }
    },
    handleReset() {
      Object.assign(this.search, {
        contractNumber: "",
        region: "",
        frameNum: "",
        dealerName: "",
        userName: "",
        createTime: []
      });
      this.handleSearch();
    }
  }
};
